package com.lagou.homework.third;

/**
 * 通话套餐类
 */
public class PhonePackage extends AbstractPackage implements PhoneInterface{
    /**
     * 通话时长
     */
    private int time;
    /**
     * 短信条数
     */
    private int msgCnt;

    /**
     * 无参构造方法
     */
    public PhonePackage() {
    }

    /**
     * 有参构造方法
     * @param time
     * @param msgCnt
     * @param monthlyCost
     */
    public PhonePackage(int time, int msgCnt, double monthlyCost) {
        super(monthlyCost);
        setTime(time);
        setMsgCnt(msgCnt);
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        if (time >= 0) {
            this.time = time;
        } else {
            System.out.println("通话时长数值不合理");
        }
    }

    public int getMsgCnt() {
        return msgCnt;
    }

    public void setMsgCnt(int msgCnt) {
        if (msgCnt >= 0) {
            this.msgCnt = msgCnt;
        } else {
            System.out.println("短信条数数值不合理");
        }
    }

    @Override
    public void show() {
        System.out.println("通话时长：" + getTime() + "，短信条数：" + getMsgCnt() + "，每月资费：" + getMonthlyCost());
    }

    @Override
    public void test(int time, PhoneCard phoneCard) {
        phoneCard.show();
        setTime(time);
        show();
    }
}
